// import axiosInstance,{setHost} from '../axiosConfig';
import { RespData } from './../../entity/response/RespData';
import { InfoDataPage } from './../../entity/home/InfoDataPage';
import { InfoDataQueryCondition } from './../../entity/query/InfoDataQueryCondition';
import { wxAppGet,wxAppPost } from '../wxRequest';
import { InfoDataModel } from '../../entity/home/InfoDataModel';
const apihost = "https://"

export async function queryInfoPageCondition(condition : InfoDataQueryCondition) : Promise<InfoDataPage> {
	// setHost(apihost)
	// const response = await axiosInstance.post<RespData>('/info', condition);
	const response = await wxAppPost<any>('/info/query', condition);
	const respData = new RespData(response.data);
	const infoDataPage = respData.getResult() as InfoDataPage;
	return infoDataPage;
}

export async function queryById(infoId : string) : Promise<InfoDataModel> {
	// setHost(apihost)
	// const response = await axiosInstance.get<RespData>('/info', { params });
	const response = await wxAppGet<any>(`info/${infoId}`, {});
	const respData = new RespData(response.data);
	const infoData = respData.getResult() as InfoDataModel;
	return infoData;
}

export function pushlishInfo(data : PublishFormData) : void {
	// setHost(apihost)
	// axiosInstance.post<RespData>('/publish', data);
	wxAppPost('/info/publish', data);
}